|
|
|
|
|
|
|
The inverse of a transformation that scales by factors Sx and Sy is one that scales by factors 1/Sx and 1/Sy. |
|
|
|
|
|
|
|
|
Finally, the inverse of a rotation through the angle q is a rotation through the angle q. |
|
|
|
|
|
|
|
|
Because Cos(q) = Cos(q) and Sin(q) = Sin(q), you can simplify this to: |
|
|
|
|
|
|
|
|
Composing Transformations |
|
|
|
|
|
|
|
|
Representing translation, scaling, and rotation as the same sort of matrices is convenient, but the real value of homogeneous coordinates comes when you compose transformations. |
|
|
|
|
|
|
|
|
Suppose you want to rotate a point P by applying a rotation matrix R and then translate the point by applying translation matrix T. You can write the transformation equation for this operation as (P * R) * T. |
|
|
|
|
|
|
|
|
Multiplication of vectors and matrices is associative. That means it does not matter whether you multiply P and R first or R and T first. This lets you rewrite the operation as P * (R * T). That means you can compute the matrix R * T first and then multiply this new matrix by the point P. Instead of multiplying the point P by two matrices, you only need to multiply it by one matrix that combines both transformations. |
|
|
|
|
|
|
|
|
This is not much of an improvement if you are only transforming a single point. Multiplying a vector by a matrix requires 9 multiplications and 6 additions. Multiplying two matrices takes 27 multiplications and 18 additions. By combining the two matrices, you save one vector/matrix multiplication. You perform an extra 27 multiplications and 18 additions to save only 9 multiplications and 6 additions. |
|
|
|
|
|
|
|
|
Most of the time, however, a program must apply a transformation to all of the points that make up some sort of object in a picture. If there are many points in the object, sav- |
|
|
|
|
|